package com.itany.corejava.code06_数组;

/**
 * @author: 石小俊
 * @date: 2023年03月03日 15:03
 * @version: 1.0
 */
public class Test01_数组的定义 {
    public static void main(String[] args) {
        // 方式一
        int[] nums = new int[5];
        // 方式二
        String names[] = new String[5];
        // 方式三
        String[] hobbies = new String[]{"吃饭","睡觉","打豆豆"};
        // 方式三的简写方式
        String[] hobbies2 = {"吃饭","睡觉","打豆豆"};

        nums[0] = 1;
        nums[2] = 3;
        names[2] = "admin";
        hobbies[1] = "玩游戏";
        hobbies2[2] = "看视频";

        System.out.println(nums[1]);
        System.out.println(nums[3]);
        System.out.println(names[0]);
        double[] ds = new double[4];
        boolean[] bs = new boolean[3];
        char[] cs = new char[3];
        System.out.println(ds[1]);
        System.out.println(bs[1]);
        System.out.println(cs[2]);
        System.out.println(hobbies[0]);
        System.out.println(hobbies[1]);

        System.out.println("nums的长度:"+nums.length);
        System.out.println("names的长度:"+names.length);
        System.out.println("hobbies的长度:"+hobbies.length);
        for(int i = 0; i < nums.length; i++){
            System.out.println(nums[i]);
        }
        for(int i = 0; i < hobbies.length; i++){
            System.out.println(hobbies[i]);
        }
        System.out.println("----------------------");
        for(String hobby : hobbies){
            System.out.println(hobby);
        }
        System.out.println(hobbies[3]);
    }
}
